<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
      .product{
        background-color: orange;
      }
    </style>
</head>
<body>
    <div id="app">
        <home-bar></home-bar>
        <product-item></product-item>
        <product-item></product-item>
        <product-item></product-item>
    </div>

    <template id="nav">
      <h2>我是应用程序的导航</h2>
    </template>

    <template id="product">
      <div class="product">
        <h2>{{title}}</h2>
        <p>商品描述，限时折扣，赶紧抢购</p>
        <p>价格：{{price}}</p>
        <button @click="favarItem">收藏</button>
      </div>
    </template>

    <script src="./lib/Vue.js"></script>
    <script>
      // 1创建app
        const app = Vue.createApp({
            data() {
                return{
                  message:"Hello Vue"
                }
            }
        })

      // 2.注册全局组件
      app.component("product-item", {
        template:"#product",
        data() {
          return {
            title:"我是商品的Item",
            price:9.9
          }
        },
        methods: {
          favarItem() {
            console.log("收藏当前的item");
          }
        }
      })

      app.component("home-bar",{
        template:"#nav"
      })
        app.mount("#app")
    </script>
</body>
</html>